home *** CD-ROM | disk | FTP | other *** search
/ NetNews Offline 2 / NetNews Offline Volume 2.iso / news / comp / lang / c-part1 / 2015 < prev    next >
Encoding:
Text File  |  1996-08-05  |  3.6 KB  |  103 lines

  1. Path: thor.tu.hac.com!collins
  2. From: collins@thor.tu.hac.com (Ron Collins)
  3. Newsgroups: alt.msdos.programmer,comp.lang.c
  4. Subject: Re: Two C problems
  5. Followup-To: alt.msdos.programmer,comp.lang.c
  6. Date: 18 Jan 1996 13:57:56 GMT
  7. Organization: Advanced Depot Systems
  8. Message-ID: <4dljl4$qj3@hacgate2.hac.com>
  9. References: <4cojnn$rgd@lugb.latrobe.edu.au> <DLCz57.5wD@ridgecrest.ca.us>
  10. NNTP-Posting-Host: thor.tu.hac.com
  11.  
  12. Drock (drock@owens.ridgecrest.ca.us) wrote:
  13. : csigjb@luxor.latrobe.edu.au () wrote:
  14.  
  15.  
  16.  
  17. : >This program should exit such that the screen is clear with the DOS prompt
  18. : >in the upper left corner, but no, it exits with a short line of text on the
  19. : >first line and then the DOS prompt on the next line. I never (or rarely)
  20. : >have these sort of problems with Pascal so why do they continuously crop up
  21. : >with C.
  22.  
  23. : Well, I'm not sure why this happens but there is a couple colutions:
  24.  
  25. : The Ugly way:
  26. :     Use the borland graphic interface to capture the data on the screen
  27. : before anything happens in the program. Then restore the buffer upon
  28. : exit. In c++, this can be done using a constructor/destructor. The
  29. : only problem is, If you are using Borland, then you have to use their
  30. : BGI drivers. THEY SUCK!!!!!!! 
  31.  
  32. This is your professional opinion?
  33.  
  34. : The clean way. Write yourself a cool little routine that stores the
  35. : contents of the active page. This can be done with a pointer  that is
  36. : assigned an absolute address to video memory and treating it as an
  37. : array. Then just use the same array to restore what the screen to it's
  38. : original status upon exit. look up 
  39.  
  40. I thought the original poster wanted a CLEAN screen, not the ORIGINAL
  41. screen returned.
  42.  
  43. : >PROBLEM 2 :
  44.  
  45. : >const escape=27;
  46. : >const cr=13;
  47. : >const bs=8;
  48.  
  49. : >while (ch!=cr)
  50. : >{
  51. : >     .
  52. : >     .
  53. : >     .
  54. : >}
  55.  
  56. : >while (ch!=escape)
  57. : >{
  58. : >     .
  59. : >     .
  60. : >     .
  61. : >}
  62.  
  63. : >If I replace the 27 with \27' or the 13 with '\13' then these loops don't
  64. : >work i.e. an infinite loop results. WHY?
  65.  
  66. : >Also if I want to do somthing like this : puts("\24 \25"); which should
  67. : >print the up and down arrows on the screen (ASCII 24 and 25), but no, it
  68. : >prints some other ASCII characters. As far as I can tell C has its own
  69. : >unique character table, at least for the control characters. WHY?
  70.  
  71. : >Sometimes I wonder whether some one needs to go back an rewrite the damn
  72. : >language so that it works sensibly and predictably like Pascal can be
  73. : >relied upon to do.
  74.  
  75. : Because when you actually press the esc key, it's ASCII value is 27,
  76. : using /27 refers to esc  when using the printf stuff. The /13 is
  77. : evaluated in those particular functions but I don';t think they are
  78. : evaluated when doing a straight compare. This has happened to me
  79. : before. If you do a printf and use /13, you get a CR , but if you read
  80. : in a CR, you get 13. Think about it, it's only a byte value and should
  81. : be treated as such. 
  82.  
  83. No.  I have no idea what you are talking about here, but it's wrong.
  84.  
  85. The tokens "13" and "\13" (note the reverse slash) refer to two
  86. different va
  87.                         -- Collins --
  88.                         
  89. -----
  90. The views expressed here are mine alone.
  91.  
  92. Ron Collins/Hughes Aircraft Company/M20,P20/Tucson Az 85706
  93. rcollins@thor.tu.hac.com    collins@seagull.rtd.com
  94. ยก----
  95. lues.  The token "13" is a decimal thirteen, which (as it
  96. happens) is the ASCII ordinal value for a carraige-return.  The token
  97. "\13" is an _octal_ eleven, which is ASCII vertical-tab, or control-K.
  98.  
  99. The reverse-slash notation is used within strings (using either octal
  100. notation \ooo or hex notation \xhhh) simply because it is a convenient
  101. method of putting otherwise non-printable characters inside a string.
  102.  
  103.